package com.app.base.service.core.pay.controller;


import com.app.base.service.core.pay.entity.OrgPay;
import com.app.base.service.core.pay.service.OrgPayService;
import com.app.base.utlis.auth.JwtHelper;
import com.app.base.utlis.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 岗位薪酬表 前端控制器
 * @author yuhag
 * @since 2022-06-12
 */
@RestController
@RequestMapping("/orgPayController")
@Api(tags = "薪酬管理")
public class OrgPayController {

    @Resource
    private OrgPayService orgPayService;

    @PostMapping("saveOrUpdateOrg")
    @ApiOperation("添加或更新岗位薪酬")
    public Result saveOrUpdateOrg(@RequestBody OrgPay orgPay, HttpServletRequest request){
        String id = JwtHelper.getMemberIdByJwtToken(request);
        orgPay.setModifyBy(id);
        orgPay.setCreatedBy(id);
        return orgPayService.saveOrUpdateOrg(orgPay);
    }

    @GetMapping("getOrgPay")
    @ApiOperation("显示所有岗位分页信息")
    public Result getOrgPay(@RequestParam(value = "current",defaultValue = "1")Long current,
                            @RequestParam(value = "pageSize",defaultValue = "10")Long pageSize){
        return orgPayService.getOrgPay(current, pageSize);
    }

    @DeleteMapping("delOrgPay/{id}")
    @ApiOperation("删除指定岗位信息")
    public Result getOrgPay(@PathVariable(value = "id")String id){
        return orgPayService.delOrgPay(id);
    }


}

